<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="com.infomanage.po.*"%>
<%@page import="com.infomanage.vo.*"%>
<%@page import="com.infomanage.service.plan.*"%>
<%@page import="org.hibernate.*"%>
<%@page import="org.hibernate.cfg.*"%>

<%
	request.setCharacterEncoding("UTF-8");
	//List<PositionPlan> postions = PositionAdjustPlanService.search(request, response, out);
	String queryValue = request.getParameter("queryValue");
	String queryName = request.getParameter("queryName");
	System.out.println("query name is:" + queryName);
	String hql = "";
	if (queryName == null) {
		hql = "From Person";
	} else {
		if (queryName.equals("name")) {
			hql = "From Person where name like '%" + queryValue + "%'";
		}
		if (queryName.equals("degree")) {
			hql = "From Person where deptId='" + queryValue + "'";
		}
	}
	Session session1 = HibernateSessionFactory.getSession();
	List list = null;
		int count = 0;
	try{
		Query q = session1.createQuery(hql);
		list = q.list();
		if (list != null) {
			count = list.size();
		}
	}catch(Exception e){
		e.printStackTrace();
	}finally{
		session1.close();
	}
%>
<html>
	<head>
		<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
		<link href="../../css/style.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="../../js/common.js"></script>
        <script type="text/javascript">
        function addphone(){
			var selectedItems = this.selectedItems;
			var delIds = "";
			for(var i = 0; i < selectedItems.length; i++){
				delIds +=";" + selectedItems[i];
		    }
			delIds = delIds.replace(";", "");
			if(delIds != ""){
				window.returnValue= delIds;
				window.top.close();
			}
			alert();
	    }
        
        </script>
	</head>
	<body rightmargin="0" bottommargin="0" leftmargin="0" topmargin="0">
		<table width="100%" height="100%" border="0" align="center"
			cellpadding="0" cellspacing="0"
			style="table-layout: fixed; background: #ffffff;">
			<tr height="29px">
				<td valign="middle" height="29px" class="td_title"
					style="padding-left: 20px; border-right: 1px #a3c6e2 solid;">
					联系人列表
				</td>
			</tr>
			
			<tr height="290px">
				<td valign="top">
					<table width="100%" height="100%" border="0" cellpadding="0"
						cellspacing="0" class="tabMain">
						<col width="10%">
						<col width="30%">
						<col width="30%">
						<col width="30%">
						<tr class="thlist">
							<td>
								<a href="#" flag="none" onclick="selectAll(this, '<%=count%>');"
									title="全选/全清" style="color: #15428B;">选择</a>
							</td>
							<td>
								手机号
							</td>
							<td>
								姓名
							</td>
							<td>
								部门
							</td>
						</tr>

						<!-- 输出数据 -->
						<tr valign="top">
							<td colspan="9" width="100%">
								<div style="width: 100%; height: 100%; overflow: auto;">
									<table class="altColorTable" cellpadding="0" cellspacing="0">
										<col width="10%">
										<col width="30%">
										<col width="30%">
										<col width="30%">
										<%
											
											if (list != null) {
												for (int i=0;i<list.size();i++) {
													
													Person person = (Person) list.get(i);
										%>
										<tr class="tdlist">
											<td>
												<input onclick="selectItem(this);" id="selBox_<%=i%>"
													type="checkbox" value="<%=person.getPhoneNo()%>">
											</td>
											<td>
												<%=person.getPhoneNo()%>
											</td>
											<td>
												<%=person.getName()%>
											</td>
											<td>

												<%=person.getDeptName()%>
											</td>

										</tr>

										<%
											}
											}
										%>
									</table>
								</div>
							</td>
						</tr>
									 
					</table>
				</td>
			</tr>
	            <tr>
				    <td colspan="1" align="center">
						<input type="button" value="添 加" onclick="javascript:addphone();">&nbsp;
					</td>
				</tr>
		</table>

		<iframe src="#" name="actionFrame" style="display: none;"></iframe>
		<!-- 分页表单 -->
<form action="addphone.jsp" name="addphoneForm" target="actionFrame">
	<input type="hidden" value="delBatch" name="actionType">
	<input type="hidden" value="batchIds" name="batchIds">
</form>
	</body>
</html>
